<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var person = { name: 'andy', hobby: ['学习', '看电影'] }

function deepClone(obj) {
  var cloneObj = new obj.constructor() //对象或者数组
//   var cloneObj = {}
  //递归出口
  if (obj === null) return obj
  if (obj instanceof Date) return new Date(obj)
  if (obj instanceof RegExp) return new RegExp(obj)
  if (typeof obj !== 'object') return obj
  for (var i in obj) {
    // eslint-disable-next-line no-prototype-builtins
    if (obj.hasOwnProperty(i)) {
      cloneObj[i] = deepClone(obj[i])
    }
  }
  return cloneObj
}

var person1 = deepClone(person)
person1.name = 'angular'
person1.hobby[0] = '玩耍'
// console.log(person)
// console.log(person1)

    </script>
</body>
</html>